#include <stdio.h>
#include <time.h>
#include <unistd.h>

int main() {
    int seconds;
    printf("请输入初始秒数: ");
    scanf("%d", &seconds);

    // 获取开始计时的时间
    time_t start_time = time(NULL);

    while (seconds > 0) {
        printf("剩余秒数: %d\n", seconds);
        seconds--;
        // 暂停1秒
        sleep(1);
    }

    // 获取计时结束的时间，也就是当前系统时间
    time_t end_time = time(NULL);
    struct tm *current_time = localtime(&end_time);
    printf("计时完毕，当前系统时间为: %04d-%02d-%02d %02d:%02d:%02d\n",
           current_time->tm_year + 1900, current_time->tm_mon + 1, current_time->tm_mday,
           current_time->tm_hour, current_time->tm_min, current_time->tm_sec);

    return 0;
}
